﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Chitiettintuc : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string MaTin = Request.QueryString["idkm"];
            string Mode = Request.QueryString["mode"];
            try
            {
                if (Mode!=null&& Mode.Equals("tuvan"))
                {
                    lbtenmuc.Text = "TƯ VẤN - LÀM ĐẸP";
                    TuVanController TuVanCtr = new TuVanController();
                    TuVanEntity tintuc = TuVanCtr.fnG_GetTuVan(MaTin);
                    lbTieuDe.Text = tintuc.TieuDe;
                    lbNgayDang.Text =tintuc.NgayNhap.ToShortDateString();
                    lbNoiDung.Text = tintuc.NoiDung;
                    lbgioithieu.Text = tintuc.GioiThieu;
                    imgHinhDaiDien.Src = "Images/TuVan/" + tintuc.HinhDaiDien+".jpg";
                    tintuc.Idtv =int.Parse(MaTin);
                    linkhead.HRef = "tuvan.aspx";
                    dtlCacTinKhac.DataSource = TuVanCtr.fnC_GetData10Diff(tintuc);
                    dtlCacTinKhac.DataBind();
                }
                else
                {
                    lbtenmuc.Text = "TIN TỨC - KHUYẾN MÃI";
                    TinTucContronller TinTucCtr = new TinTucContronller();
                    TinTucKhuyenMaiEntity tintuc = TinTucCtr.fnG_GetTinTuc(MaTin);
                    tintuc.Idkm = int.Parse(MaTin);
                    lbTieuDe.Text = tintuc.TieuDe;
                    lbNgayDang.Text = tintuc.NgayNhap.ToShortDateString();
                    lbNoiDung.Text = tintuc.NoiDung;
                    lbgioithieu.Text = tintuc.GioiThieu;
                    imgHinhDaiDien.Src = "Images/TinTuc/" + tintuc.HinhAnhDaiDien + ".jpg";
                    linkhead.HRef = "dstintuc.aspx";
                    dtlCacTinKhac.DataSource = TinTucCtr.fnC_GetTinTuc10Diff(tintuc);
                    dtlCacTinKhac.DataBind();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}